Add check_khuap_klam to pythainlp.util for Thai consonant cluster detection - #1308
Merged
Conversation
…ection Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add function to check Thai consonant clusters
Add Mar 7, 2026
check_khuap_klam to pythainlp.util for Thai consonant cluster detection
Member
|
@copilot Add docs to docs/api/util.rst |
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Contributor
Author
wannaphong
marked this pull request as ready for review
March 7, 2026 06:50
wannaphong
approved these changes
Mar 7, 2026
wannaphong
requested changes
Mar 7, 2026
| - Reorganize noauto test suite by dependency groups | ||
| (torch, tensorflow, onnx, cython, network) #1290 | ||
| - Add BLEU, ROUGE, WER, and CER metrics to pythainlp.benchmarks #1295 | ||
| - Add `check_khuap_klam` to `pythainlp.util` for checking Thai consonant clusters #1308 |
Member
There was a problem hiding this comment.
@copilot Fix Line length
Check failure: Line length
CHANGELOG.md:41:81 MD013/line-length Line length [Expected: 80; Actual: 87]
Contributor
Author
There was a problem hiding this comment.
Fixed in c4482ea — wrapped the line to keep it within 80 characters.
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Member
|
@copilot Move the testset to tests/compact. It is not core testset. |
Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
Contributor
Author
|
wannaphong
approved these changes
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What do these changes do
Adds
check_khuap_klam(word)topythainlp.util— a function that classifies Thai words by consonant cluster (Kham Khuap Klam, คำควบกล้ำ) type.Return values:
True— true consonant cluster (คำควบกล้ำแท้): pronunciation merges two consonants (initial ก ข ค ต ป ผ พ ฟ บ + ร ล ว)False— false consonant cluster (คำควบกล้ำไม่แท้): written as cluster (ทร จร ศร สร ซร) but not pronounced as oneNone— not a consonant clusterWhat was wrong
No utility existed in PyThaiNLP to programmatically identify Thai consonant clusters or distinguish true clusters from false ones.
How this fixes it
pythainlp/util/khuap_klam.py— new module; usespronunciate(word, engine="w2p")(lazy import to avoid circular imports) to get the phonemic reading, then applies regex checks on both the written form and the pronunciation to classify the cluster type.pythainlp/util/__init__.py— exportscheck_khuap_klam(added to__all__and import block, both in alphabetical order).tests/compact/testc_util.py— covers all three return values and the empty-string edge case (placed in the compact test suite as it requires thew2ptransliteration engine).CHANGELOG.md— entry added under the current dev version (line-length fixed to comply with MD013).docs/api/util.rst— API documentation entry added in alphabetical order.Your checklist for this pull request
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.